#php ternary operator
Explore tagged Tumblr posts
dailyaspirants · 1 year ago
Text
Python Ternary Operator
Visit our site for free project source codes-- dailyaspirants.com . . Follow @dailyaspirants for more content on website development, programming languages like Python, PHP, SEO, Free tools..etc.
0 notes
w3codeworld · 5 years ago
Link
If the structure is one of the most important and essential features in a computer programming language. The if statement in PHP helps us to execute the code fragments conditionally. This structure is almost similar to the if the structure in C. If statement in PHP returns a boolean value as a result, either true or false.
0 notes
openprogrammer · 2 years ago
Photo
Tumblr media
technique of the day Ternary operator Javascript #javascript #html #programming #css #coding #java #python #developer #programmer #webdeveloper #webdevelopment #code #coder #php #webdesign #software #softwaredeveloper #computerscience #codinglife #reactjs #technology #frontend #development #programmers #js #web #softwareengineer #programmingmemes #linux #javascriptdeveloper https://www.instagram.com/p/Cn3_ZP7PMwI/?igshid=NGJjMDIxMWI=
27 notes · View notes
initialcommit · 5 years ago
Photo
Tumblr media
Refresher on how to write the Ternary Operator in Python, Java, JavaScript, C, and PHP. Follow @initialcommit for more programming content. Check out our website https://initialcommit.io for programming articles, books, live sessions, and how to create your own code-oriented website. #initialcommit #ternary #operator #python #pythonprogramming #java #javaprogramming #javascript #cprogramming #php #programming #coding #learnprogramming #learncoding #softwaredevelopment https://www.instagram.com/p/CAQCC73lYtl/?igshid=8ul1xnwrb1bp
0 notes
magic3w · 6 years ago
Text
Testing the ?? operator in PHP
The ?? operator was introduced to PHP with PHP 7.0, but sadly I haven't been using it very much - and the other day I realized that I haven't seen it around much either.
?? is one of the most significant bits of syntactical sugar that PHP introduced when it added the new operators to PHP7, it basically means that something like this:
$id = isset($_GET['id']) && !empty($_GET'id'])? $_GET['id'] : false;
Can now be written with a much less repetitive and much more expressive statement that looks like:
$id = $_GET['id']?? false;
It looks much better, doesn't it? It's so much stronger and more readable that it seems like a no-brainer for people to use it. But still, it's 2019, PHP7 has been around for years and I still get to read recent code that is not taking advantage of it.
I made a mental note to start using it more, and have realized that the thing keeping me from using it was the fact that I wasn't sure if it would work exactly the same way as the long bulky statement.
I wrote a few tests to ensure that it was compatible with magic methods of objects and the ArrayAccess interface. We use them quite often to write more readable code, and they've been a regular source of headaches in the past. Here's the script I used: https://3v4l.org/v7YYP
Conclusion
I am happy to report that ?? is virtually identical to the long ternary expression that (sometimes also the if statement) that people are using. And it also does not raise those Undefined index errors when reading your input variables.
1 note · View note
mszegedy · 6 years ago
Text
7 am thought: is there a worse syntactic decision ever made in a popular programming language than matlab having "..." as its line continuation operator? like okay php's ternary operator being left-associative is definitely much worse but i'm thinking more in terms of symbol choice (i.e. vocabulary) than grammar. is there anything less convenient than needing to set aside 4 entire characters to continue a line?
having "<-" as the assignment operator in r is up there i guess but i think "..." is still worse since it's one character longer and explicitly goes in a place where you're by definition already running out of space
i wonder if the decision to make macros syntactically indistinguishable from functions in lisp counts. it killed the entire language family
…but it was also considered lisp's greatest feature so idk
2 notes · View notes
duxiyiko-blog · 6 years ago
Text
Best way to prepare for PHP interview
PHP is one among the programming languages that are developed with built-in web development functions. The new language capabilities contained in PHP 7 ensure it is simpler for developers to extensively increase the performance of their web application without the use of additional resources. interview questions and answers topics for PHP They can move to the latest version of the commonly used server-side scripting language to make improvements to webpage loading without spending extra time and effort. But, the Web app developers still really should be able to read and reuse PHP code quickly to maintain and update web apps in the future.
Helpful tips to write PHP code clean, reliable and even reusable
Take advantage of Native Functions. When ever writing PHP code, programmers may easily achieve the same goal utilizing both native or custom functions. However, programmers should make use of the built-in PHP functions to perform a number of different tasks without writing extra code or custom functions. The native functions should also help developers to clean as well as read the application code. By reference to the PHP user manual, it is possible to collect information about the native functions and their use.
Compare similar functions. To keep the PHP code readable and clean, programmers can utilize native functions. However they should understand that the speed at which every PHP function is executed differs. Some PHP functions also consume additional resources. Developers must therefore compare similar PHP functions and select the one which does not negatively affect the performance of the web application and consume additional resources. As an example, the length of a string must be determined using isset) (instead of strlen). In addition to being faster than strlen (), isset () is also valid irrespective of the existence of variables.
Cache Most PHP Scripts. The PHP developers needs keep in mind that the script execution time varies from one web server to another. For example, Apache web server provide a HTML page much quicker compared with PHP scripts. Also, it needs to recompile the PHP script whenever the page is requested for. The developers can easily eliminate the script recompilation process by caching most scripts. They also get option to minimize the script compilation time significantly by using a variety of PHP caching tools. For instance, the programmers are able to use memcache to cache a lot of scripts efficiently, along with reducing database interactions.
common asked php interview questions and answers for freshers
Execute Conditional Code with Ternary Operators. It is actually a regular practice among PHP developers to execute conditional code with If/Else statements. But the programmers want to write extra code to execute conditional code through If/Else statements. They could easily avoid writing additional code by executing conditional code through ternary operator instead of If/Else statements. The ternary operator allows programmers to keep the code clean and clutter-free by writing conditional code in a single line.
Use JSON instead of XML. When working with web services, the PHP programmers have option to utilize both XML and JSON. But they are able to take advantage of the native PHP functions like json_encode( ) and json_decode( ) to work with web services in a faster and more efficient way. They still have option to work with XML form of data. The developers are able to parse the XML data more efficiently using regular expression rather than DOM manipulation.
Replace Double Quotes with Single Quotes. When writing PHP code, developers are able to use either single quotes (') or double quotes ("). But the programmers can easily improve the functionality of the PHP application by using single quotes instead of double quotes. The singular code will speed up the execution speed of loops drastically. Similarly, the single quote will further enable programmers to print longer lines of information more effectively. However, the developers will have to make changes to the PHP code while using single quotes instead of double quotes.
Avoid Using Wildcards in SQL Queries. PHP developers typically use wildcards or * to keep the SQL queries lightweight and simple. However the use of wildcards will impact on the performance of the web application directly if the database has a higher number of columns. The developers must mention the needed columns in particular in the SQL query to maintain data secure and reduce resource consumption.
However, it is important for web developers to decide on the right PHP framework and development tool. Presently, each programmer has the option to decide on a wide range of open source PHP frameworks including Laravel, Symfony, CakePHP, Yii, CodeIgniter, and Zend. Therefore, it becomes necessary for developers to opt for a PHP that complements all the needs of a project. interview questions on PHP They also need to combine multiple PHP development tool to decrease the development time significantly and make the web app maintainable.
php interview questions for freshers
youtube
1 note · View note
basitnaeem1992-blog · 6 years ago
Text
PHP is one amongst the programming languages that were developed with inbuilt net development capabilities. The new language options enclosed in PHP seven any makes it easier for programmers to boost the speed of their net application considerably while not deploying extra resources. They programmers will switch to the foremost recent version of the wide used server-side scripting language to enhance the load speed of internet sites while not swing beyond regular time and energy. however the net application developers still want target the readability and reusability of the PHP code to take care of and update the net applications quickly in future.
12 Tips to write down Clean, rectifiable, and Reusable PHP Code
1) benefit of Native Functions While writing PHP code, the programmers have choice to accomplish identical objective by victimisation either native functions or custom functions. however the developers should benefit of the inbuilt functions provided by PHP to accomplish a spread of tasks while not writing extra code or custom functions. The native functions can any facilitate the developers to stay the appliance code clean and decipherable. they'll simply gather info concerning the native functions and their usage by touching on the PHP user manual.
Another way to check phpstorm key shortcuts
2) Compare Similar Functions The developers will use native functions to stay the PHP code decipherable and clean. however they need to keep in mind that the speed of individual PHP functions differs. Also, bound PHP functions consume extra resources than others. Hence, the developers should compare similar PHP functions, and select the one that doesn't have an effect on the performance of the net application negatively and consume extra resources. as an example, they need to verify the length of a string by victimisation isset() rather than strlen(). additionally to being quicker than strlen(), isset() conjointly remains valid in spite of the existence of variables.
3) Cache Most PHP Scripts The PHP programmers should keep in mind that the script execution time differs from one net server to a different. as an example, Apache net server serve a HTML page abundant quicker than PHP scripts. Also, it has to recompile the PHP script on every occasion the page is requested for. The programmers will simply eliminate the script recompilation method by caching most scripts. They even have choice to scale back the script compilation time considerably by employing a style of PHP caching tools. as an example, the programmers will use memcache to cache an oversized variety of scripts expeditiously, at the side of reducing info interactions.
4) Execute Conditional Code with Ternary Operators It is a typical observe among PHP developers to execute conditional code with If/Else statements. however the developers got to writing extra code to execute conditional code through If/Else statements. they'll simply avoid writing extra code by corporal punishment conditional code through ternary operator rather than If/Else statements. The ternary operator helps programmers to stay the code clean and clutter-free by writing conditional code during a single line.
5) Keep the Code decipherable and rectifiable Often programmers notice it intimidating perceive and modify the code written by others. Hence, they have beyond regular time to take care of and update the PHP applications expeditiously. whereas writing PHP code, the programmers will simply build the appliance simple to take care of and update by describing the usage and significance of individual code snippets clearly. they'll simply build the code decipherable by adding comments to every code piece. The comments can build it easier for alternative developers to form changes to the present code in future while not swing beyond regular time and energy.
6) Use JSON rather than XML While operating with net services, the PHP programmers have choice to use each XML and JSON. however they'll continuously benefit of the native PHP functions like json_encode( ) and json_decode( ) to figure with net services during a quicker and a lot of economical manner. They still have choice to work with XML style of information. The programmers will break down the XML information a lot of expeditiously by victimisation regular expression rather than DOM manipulation.
7) Pass References rather than worth to Functions The intimate PHP programmers ne'er declare new categories and strategies only if they become essential. They conjointly explore ways in which to recycle the categories and strategies throughout the code. However, they conjointly perceive the actual fact that a perform may be manipulated quickly by passing references rather than values. they'll any avoid adding additional overheads by passing references to the perform rather than values. However, they still got to make sure that the logic remains unaffected whereas passing relevancy the functions.
8) flip Error coverage on in Development Mode The developers should establish and repair all errors or flaws within the PHP code throughout the event method. They even have to place overtime and energy to mend the writing errors and problems known throughout testing method. The programmers merely set the error coverage to E_ALL to spot each minor and major errors within the PHP code throughout the event method. However, they need to flip the error coverage choice off once the appliance moves from development mode to production mode.
9) Replace inverted comma with Single Quotes While writing PHP code, programmers have choice to use either single quotes (') or inverted comma ("). however the developers will simply enhance the performance of the PHP application by victimisation single quotes rather than inverted comma. the only code can increase the speed of loops drastically. Likewise, the only quote can any change programmers to print longer lines of data a lot of expeditiously. However, the developers got to build changes to the PHP code whereas victimisation single quotes rather than inverted comma.
10) Avoid victimisation Wildcards in SQL Queries PHP programmers typically use wildcards or * to stay the SQL queries compact and easy. however the employment of wildcards might have an effect on the performance of the net application directly if the info includes a higher variety of columns. The programmers should mention the desired columns specifically within the SQL question to stay information secure and scale back resource consumption.
11) Avoid corporal punishment info Queries in Loop The PHP programmers will simply enhance the net application's performance by not corporal punishment info queries in loop. They even have variety of choices to accomplish identical results while not corporal punishment info queries in loop. as an example, the developers will use a strong WordPress plug-in like question Monitor to look at the info queries at the side of the rows laid low with them. they'll even use the debugging plug-in to spot the slow, duplicate, and incorrect info queries.
12) ne'er Trust User Input The sensible PHP programmers keep the net application secure by ne'er trusting the input submitted by users. They continuously check, filter and sanitize all user info to guard the appliance from varied security threats. they'll any forestall users from submitting inappropriate or invalid information by victimisation inbuilt functions like filter_var(). The perform can check for applicable values whereas receiving or process user input.
However, it's conjointly necessary for the net developers to select the correct PHP framework and development tool. At present, every technologist has choice to choose between a large vary of open supply PHP frameworks as well as Laravel, Symfony, CakePHP, Yii, CodeIgniter and Iranian language. Hence, it becomes essential for programmers to select a PHP that enhances all wants of a project. They conjointly got to mix multiple PHP development tool to scale back the event time considerably and build the net application rectifiable.
1 note · View note
afgprogrammer · 4 years ago
Photo
Tumblr media
PHP Conditional Statements: Very often when you write code, you want to perform different actions for different conditions. You can use conditional statements in your code to do this. In PHP we have the following conditional statements: if statement - executes some code if one condition is true if...else statement - executes some code if a condition is true and another code if that condition is false if...elseif...else statement - executes different codes for more than two conditions Ternary Operators In addition to all this conditional statements, PHP provides a shorthand way of writing if…else, called Ternary Operators. The statement uses a question mark (?) and a colon (:) and takes three operands: a condition to check, a result for TRUE and a result for FALSE. #php #code #coding #phpdevelooer #developer #afgprogrammer #codesnippet #phpprogramming https://www.instagram.com/p/CLRhNqpjQyn/?igshid=msos8smu9fd3
0 notes
w3codeworld · 5 years ago
Link
PHP stands for hypertext preprocessor. PHP is an open-source scripting language that is mainly used in the web development. It is embedded in HTML for developing web pages. PHP is for managing session track, dynamic control, database, etc. PHP code of a web page runs on a web server by a particular PHP interpreter.
0 notes
globalmediacampaign · 5 years ago
Text
PHP empty() function use with MySQL NULL
PHP provides a handy function, empty(), that is used to determine whether a variable is empty. Perhaps that is a bit confusing to someone unfamiliar with the empty() function and I can see how. In this blog post, I will cover: what empty() means in PHP, what the empty() function does, and a use case pairing up empty() with the PHP ternary operator conditional construct. Both used in combination with the MySQL NULL value. Continue reading and see examples of empty()… Photo by Debby Hudson on Unsplash Self-Promotion: If you enjoy the content written here, by all means, share this blog and your favorite post(s) with others who may benefit from or like it as well. Since coffee is my favorite drink, you can even buy me one if you would like! I’ll use these various variables for examples throughout the post: $name = 'Josh'; $another_name = NULL; $some_name = ''; $an_age = 0; $another_age = '0'; $different_age = 12; Before we see what values are returned when the above variables are passed to empty(), let’s visit the PHP documentation on empty() for additional information, that way we know what to expect. Here is the description: “Determine whether a variable is considered to be empty. A variable is considered empty if it does not exist or if its value equals FALSE. empty() does not generate a warning if the variable does not exist.” empty() returns a value – either TRUE or FALSE – depending on if the variable that is passed to empty() as an argument exists and is either non-empty or non-zero. So what exactly is non-empty and non-zero? Let’s find out… Echo PHP empty() function in the browser For more context, I’ll echo out the return values of each of the below calls to empty(), passing in the previously defined variables above as arguments in each call: echo '$name variable empty value is: '.empty($name).' '; echo '$another_name variable empty value is: '.empty($another_name).' '; echo '$some_name variable empty value is: '.empty($some_name).' '; echo '$an_age variable empty value is: '.empty($an_age).' '; echo '$another_age variable empty value is: '.empty($another_age).' '; echo '$different_age variable empty value is: '.empty($different_age).' '; Return results from empty echo’ed in the browser Understanding PHP empty() function What does empty consider to be empty? empty() considers any of these values to be empty: The empty string – “” The integer 0 (zero) The float 0.0 The string “0” The NULL value. The FALSE boolean An empty array(). Based on the above list, the first variable, ‘$name’, and the last variable ‘$different_age’, are not considered empty, as they both have actual values (none of which are those included on the empty list). When passed to empty() as arguments, both variables return FALSE whereas all of the other variables return TRUE. In PHP, a FALSE can be considered 0 (zero) where a TRUE value can be considered 1. For more information on PHP booleans, visit the online PHP Booleans documentation. In order to see the actual boolean result, we can use the var_dump() function, passing the empty() function call with the variable parameter as var_dump()‘s own parameter: echo var_dump(empty($name)).' '; echo var_dump(empty($another_name)).' '; echo var_dump(empty($some_name)).' '; echo var_dump(empty($an_age)).' '; echo var_dump(empty($another_age)).' '; echo var_dump(empty($different_age)).' '; Using var_dump to echo out boolean values. What can we use the PHP empty() function for? Now that we have an idea of what empty() does, we can use it in a simple example and see the benefits of such a handy function. I have recently used an empty() trick in a LAMP stack application I have been working on and just had to share it here on my blog (although it is by no stretch of the imagination, sacred knowledge). Suppose we have this MySQL table, structure, and data: Current data in the project_pdf table The requirement is, provide a simple button for each project name in the table. However, each rows’ button should only be clickable if there is a pdf document file for that projects’ table row. We can use empty() to test the ‘pdf_doc’ column variable and determine if the value is NULL or not and set the button accordingly. Recall NULL is considered empty and if passed to the empty() function will return TRUE. We first need a connection to the database along with a SELECT query, retrieving all rows from the ‘project_pdf’ table: include __DIR__.'/includes/DatabaseConnection.php'; $query = "SELECT `id`, `project_name`, `pdf_doc` FROM `project_pdf` ORDER BY `project_name` ASC;"; $results = $pdo->query($query); foreach ($results as $row) {     $rows[] = ['id' => $row['id'], 'project_name' => $row['project_name'], 'pdf_doc' => $row['pdf_doc']]; } The next part of the script contains the dynamic PHP, which provides a list of Bootstrap buttons; one for each of the returned records from the MySQL database: PHP foreach loop using empty() function to set button attributes Notice the call to empty() in the button class attribute. Using the PHP ternary operator, each button’s ‘$row[‘pdf_doc’]’ value is checked. The ternary operator uses this syntax:     conditional_test ? truth_result_code : false_result_code If the ‘$row[‘pdf_doc’]’ value is NULL, then empty() returns TRUE. That buttons’ class attribute is set to btn btn-secondary disabled along with the disabled attribute itself. Should the ‘$row[‘pdf_doc’]’ value not be empty() (returns false), then the class attribute is set to btn btn-primary (with no disabled attribute) and stays active. The following screenshots show the active and inactive buttons for each MySQL table row: Button list of all current projects Button in active state. Mouse cursor on Bootstrap inactive button. Notice the ‘Project 3’ button is inactive since its row in the database has a NULL value for the ‘pdf_doc’ column. Be sure and check out these 2 posts on storing and retrieving a .pdf file with PHP and the MySQL BLOB datatype: Use MySQL BLOB column with PHP to store .pdf file PHP MySQL BLOB PDF: Display in Browser I hope through this post, you can find ways to use empty() for similar types of functionality where you see fit. I think it’s pretty neat myself. What creative ways have you used empty()? Tell me about them in the comments below. I’d love to know and learn more uses myself. Like always, if you see anything in the code I can improve on or correct, please let me know via the comments below. Like what you have read? See anything incorrect? Please comment below and thanks for reading!!! A Call To Action! Thank you for taking the time to read this post. I truly hope you discovered something interesting and enlightening. Please share your findings here, with someone else you know who would get the same value out of it as well. Visit the Portfolio-Projects page to see blog post/technical writing I have completed for clients. To receive email notifications (Never Spam) from this blog (“Digital Owl’s Prose”) for the latest blog posts as they are published, please subscribe (of your own volition) by clicking the ‘Click To Subscribe!’ button in the sidebar on the homepage! (Feel free at any time to review the Digital Owl’s Prose Privacy Policy Page for any questions you may have about: email updates, opt-in, opt-out, contact forms, etc…) Be sure and visit the “Best Of” page for a collection of my best blog posts. Josh Otwell has a passion to study and grow as a SQL Developer and blogger. Other favorite activities find him with his nose buried in a good book, article, or the Linux command line. Among those, he shares a love of tabletop RPG games, reading fantasy novels, and spending time with his wife and two daughters. Disclaimer: The examples presented in this post are hypothetical ideas of how to achieve similar types of results. They are not the utmost best solution(s). The majority, if not all, of the examples provided, is performed on a personal development/learning workstation-environment and should not be considered production quality or ready. Your particular goals and needs may vary. Use those practices that best benefit your needs and goals. Opinions are my own. The post PHP empty() function use with MySQL NULL appeared first on Digital Owl's Prose. https://joshuaotwell.com/php-empty-function-use-with-mysql-null/
0 notes
xiaoquebanxiaoqueban · 5 years ago
Text
China s battery recovery rate will reach 60 in 2025 BMW s new energy sales in China will increase by 40
On the afternoon of August 14, the PHEV of Beijing Hyundai led PHEV was officially launched on the market, and three new models were launched, namely 1.6L PHS Changxing, 1.6L PHX lexing and 1.6L PHP Zhixing. The official price range is 197800-2218000 yuan, and the subsidised sales price is 1578-178800 yuan. Leading PHEV is the second plug-in hybrid product of Beijing Hyundai after Sonata PHEV. It is also one of the few compact plug-in hybrid cars at present.
source: the first electric network
7. The exposure duration of Euler R2 spy photos will not be less than 350km
recently, we obtained a group of spy photos of Euler R2 mass production version. As the second product of Euler R series, the new car continues the lovely design style of Euler R1 in terms of electric tourist car</a> appearance. According to the disclosure of information reported by the Ministry of industry and information technology, the new car is equipped with a maximum power 35kw (48ps) drive motor and ternary lithium-ion power battery pack provided by Ningde times. The car is another model built on the EULA me platform after Euler R1, and is expected to be officially launched within the year.
source: e-Car
8. Two power versions of Tengshi x application chart will be exposed
recently, we obtained the application information of Tengshi x from the Ministry of industry and information technology of the people's Republic of China, which is positioned as a 7-seat medium-sized SUV. The new car will provide pure electricityVersion and plug-in hybrid version. According to the previous official information, its 0-100km / h acceleration or within 5 seconds, in which the pure electric version of NEDC's comprehensive range may reach more than 500km.
source: Automobile home
9! Intelligent technology expert Shen Shui Shui joined United Automobile Group Co., Ltd.
unizhong automobile won the top position again! Recently, following Zhou Jiang, Wang Kefeng and other big names in the industry to join United Automobile, United Automobile has ushered in a new personnel appointment. Shen shuihui, an intelligent technology expert, has officially joined United Automobile. He is the chief chief engineer and President of the intelligent driving research institute. He is responsible for the research and development of powertrain and control, automatic driving (ADAS), intelligent network connection and vehicle electronic and electrical appliances.
source: first electric network
10. Li Bin's internal letter announced that Zheng Xiancong, the co-founder of Weilai, was "retired"
an internal email from Li Bin, the founder and executive vice president of Weilai automobile, was retired. Li Bin said in the email that after his retirement, Zheng Xiancong will continue to serve as his personal consultant, support the company in terms of supply chain and partnership, and will continue to serve as the chairman of Weilai drive technology, and continue to guide Weilai to drive the development of science and technology from the strategic level. At the same time, Li Bin announced that Zhong Wanli, vice president of supply chain, would report directly to him. Zeng Shuxiang will become CEO of Weilai drive technology from now on, and will be fully responsible for the work of Weilai driving technology.
source: Tencent frontline
source 11. The number of electric vehicle charging piles in Germany has reached 20650, with a year-on-year increase of more than 50%
on August 14, Stefan kapferel, chairman of the German Federal Energy and Water Resources Economic Association, said that the number of electric vehicle charging piles in Germany is growing rapidly, but the expansion of charging piles near residential and office areas needs to be accelerated. The number of public charging piles for electric vehicles in Germany now stands at 20650, up more than 50% from the same period last year, kapferel said in a press release.
source: Xinhua News Agency
12, it's a low-speed shuttle! New York's first self driving service opened its doors to meet visitors
on August 7, us time, the first self driving shuttle service in New York was finally launched in Brooklyn. Optimus ride (born in MIT) is responsible for the operation of the self driving shuttle service. There are six 6-seat electric shuttles in the service fleet. However, the first phase of the six vehicles can only operate in the closed industrial area of "Brooklyn naval dock", which covers 300 acres.
source: Lei feng.com
13. China Unicom and FAW Jiefang strategically cooperate to promote the development of intelligent network of commercial vehicles
it was reported on August 14 that China Unicom and FAW Jiefang held a signing ceremony in Changchun, and both sides signed a strategic cooperation agreement to jointly promote the development of intelligent networking of commercial vehicles. According to the strategic agreement, the two sides will provide Internet of vehicles, industrial Internet, cloud computing, big data and comprehensive information servicesThe company is committed to the development of high-quality, high-quality vehicle networking, vehicle testing and other fields (such as >electric shuttle bus</a> high-quality vehicle networking, vehicle networking, etc.), as well as joint development of high-quality vehicle manufacturing and application (such as mobile Internet, vehicle networking, etc.), as well as the development of high-quality vehicle service, such as mobile Internet, multi vehicle test, etc.
source: Securities Times
14. Indian auto sales suffered the biggest drop in 20 years
the Indian auto market has been very bleak in recent one year. Not only has the sales volume fallen for nine consecutive months, but also for the last four consecutive months, the sales volume has dropped by more than 20% year-on-year, which further fell in July. According to the data just released by the association of Indian automobile manufacturers, the sales of passenger cars in India fell by 31% in July, the biggest drop in >electric buggy suppliers</a> nearly 20 years.
source: Sina automobile
0 notes
anaymalpani · 5 years ago
Text
“WHY DOES PHP SUCK?”
Tumblr media
There are so many awful things involved in this abomination of a high-level programming language, it outright exceeds full-blown ridicularity. PHP sucks on so many levels that it isn’t even funny anymore mocking it. To be honest, it just makes me sad.  Its popularity is completely undeserved and I repeatedly find myself facepalming, thinking about how it is possible that this piece of junk gained even the slightest hint of acceptance. Believe it or not, I basically created this website just so that I could rant about PHP at an appropriate place.So then tell me, why does it suck?
If you think about what’s important in terms of programming languages, you might come up with some buzzwords like portability, performance, predictability, consistency, and so on. Unfortunately, PHP doesn’t really have any of these characteristics. While portability and performance are usually implementation-dependent, predictability and consistency are logical traits that I expect to find in any language. I’d even go so far and say that PHP deliberately tries to be the complete opposite of what makes up a good language, with every “feature” being somehow broken in its own way. Anyway, let’s get started.
LANGUAGE DESIGN
Tumblr media
As any other language, PHP took a look at its predecessors. Its syntax seems to be heavily influenced by Java with a slightly lower degree of verbosity while its library framework is more like a bunch of C-style functions with cryptic names. It is also related to Perl — which is probably where it got some of it quirks from. Naturally, it comes with some of its own, totally arbitrary design choices that almost never seem to make sense. There is one underlying issue with all this: PHP doesn’t follow a distinct path.
HISTORY & PARADIGMS
Obviously, PHP started as a procedural language – or did it? Actually, it started as some weird html-meta-language, called PHP/FI that looked something like this:
1 2 3 4 5 6 7 <!–include /text/header.html–> <!–sql database select * from table where user=’$username’–> <!–ifless $numentries 1–> Sorry, that record does not exist<p> <!–endif exit–> Welcome <!–$user–>! <!–include /text/footer.html–>
Tumblr media
Doesn’t this just look beautifully awful?  It might have had some kind of weird masochistic use a couple of centuries ago for simple websites, but still — Yikes! After that, PHP seemed to have adopted a more natural kind of the procedural paradigm as we know it today, fairly similar to the style found in C. Nowadays it tries hard to be like Java or other modern, object oriented languages. From the start, PHP has been designed with beginners in mind whose sole goal is to create simple, database driven websites. Of course, this is totally fine except that it grew too large over time. Apparently, way too less brainpower has been invested into scalability (or into anything) during the probably non-existent design process. There is nothing wrong with a language that is designed for small-scale applications, but what PHP has become and what it is being used for is clearly far away from all intentions during its inception — a personal toolkit for its creator.
TYPE SYSTEM
PHP uses the dynamic typing approach with types being determined at runtime based on how they are used in any particular situation. This already sucks in my opinion, but I won’t hold it against PHP since it is fairly common among scripting languages. What’s worse is just that there isn’t even a way to declare variables. Variables are created and initialized whenever they are used for the first time, which is just bound to result in errors that are caused by typos.
Arrays are yet another weird quirk you’ll have to endure. They are not just numerically indexed but actually a freakish crossbreed of pretty much everything and can be treated as an array, list, hash table, dictionary, collection, stack, queue, and probably more. Before classes were added to PHP 4, there were no other data structures.
CASTING
Tumblr media
The language provides C-style type conversions like $foo = (int)$bar;, even though there is no type-safety. This is strange, given that int doesn’t actually exist and isn’t used anywhere else. The same goes for other primitives. I also stumbled across the (unset) cast that always evaluates to null — there doesn’t seem to be any useful purpose for it.  There are so many rules involved — or I’d rather call it different conditions under very specific circumstances — that make type conversions unnecessarily difficult and complex to get correct. Be prepared, you will face hard-to-detect errors that will make your life miserable.
TYPE HINTING
Hold on… didn’t I just mention before that types cannot be specified because dynamic typing is being used? Well yes — except when it comes to classes as parameter types for functions and methods. To be specific, I mean classes only. Specifying string or boolean will result in a runtime error when the function is called, stating that the argument “must be an instance of string, string given”. This is PHP’s pathetic attempt at some weird kind of static typing. Consider this declaration:
1 2 3 function type_hinted_function(SomeClass $foo) { // }
The function must be called with a valid instance of SomeClass. If $foo happened to be null or any non-class type, it crashes. Well at least it’s something… Oh and before I forget, return value types cannot be hinted, of course. Actually, there is an experimental concept called SPL Types that allows type hinting with basic types. Apparently, creating a wrapper class for basic types in order to achieve basic functionality seemed to be a good idea.
INTEGER OVERFLOWS
Take a moment to reflect on how non-retarded programming languages handle integer overflows (or underflows for that matter). I can think of three main approaches to handle such scenarios and give you one language each:
C/C++ ignores the fact that an overflow happened and starts counting from the other side (usually, although technically the behavior is undefined according to the language specifications).
C# will throw an exception indicating the overflow, given the operation was carried out within a checked block.
Ruby features type promotion and automatically switches to arbitrary integers to deliver the correct result.
Now PHP follows a completely different approach. Instead of doing something sensible, it automatically converts the value to float. Let that sink in for a while. Even worse, there is no easy mechanism to detect such overflows. Programmers that have to deal with numbers larger than signed 32bit integers* are required to use packages like GMP or BCMath. PHP does not support unsigned variables. *Refer to Section Platform Dependency.
CASE SENSITIVITY
Of course the inconsistency mows everything down here too. PHP code is both case-sensitive and case-insensitive, depending on the specific identifiers. In PHP, variables, constants and array keys are case-sensitive. The same rule goes with class member variables and class constants. However, keywords, functions and methods are case-insensitive. While this might not be a big issue, it may still cause problems when using autoloaders on case-sensitive file systems.
OPERATOR MADNESS
Another problem that commonly arises with languages that are not type-safe is dealing with type conversions while using operators. Normal languages clearly define the behavior in a logical way, however, PHP is a special case again here because the outcome seems to be pretty much unpredictable. Actually, let me give you a humble advice at this point:Do not, under any circumstances, use “==” if you’re not 100% positive that what you’re doing is correct.
Instead, use the === operator to test both type and value. The standard equality operator == is completely broken and a straight out security hazard. According to the operator documentation, PHP favors numerical comparisons over what is actually specified in the statement.
If you compare a number with a string or the comparison involves numerical strings, then each string is converted to a number and the comparison performed numerically. These rules also apply to the switch statement.
I felt like doing a little testing on this one and created a script that compares several values with each other, outputting a nicely formatted table to visualize the madness. This is the result:
Tumblr media Tumblr media
Interestingly enough, PHP thinks the boolean value true is equals to the string "foobar" while "foobar" is equal to 0, yet 0 is not equal to true. This should nicely demonstrate that there is — again — some weird inconsistency going on, with comparison results being non-transitive. Due to the fact that PHP converts “numerical strings” into numbers, the strings "4779" and "0x12AB" are also considered equal. What the hell. 
It is a good thing that there is an additional operator === for testing whether two values are identical, i.e. of the same type with the same value. Unfortunately, this is only partially useful. While this operator solves the issues with the equality operator ==, it does not solve issues with greater-than or less-then comparisons. Frankly, there are no according >== or <== operators, so you’re stuck with the previously mentioned problems. Speaking of inconsistencies, PHP seems to be the only language in existence that implements a left-associative ternary operator ?:, rendering it useless for if-then-else-if-else constructs. Have a look at the following snippet and tell me, what output you’d expect.
1 2 3 4 5 6 7 8 $initial = ‘J’; $name = (($initial == ‘M’) ? ‘Mike’ : ($initial == ‘J’) ? ‘John’ : ($initial == ‘C’) ? ‘Catherine’ : ($initial == ‘T’) ? ‘Thomas’ : ‘unknown’); echo $name; echo “\n”;
Are you with me if I say I’d expect "John", since the initial is "J"? Well, obviously this is way too logical for PHP to grasp, so the answer is actually "Thomas". Nice try, anyway.
FUNCTION & CLASS LIBRARY
So, with a language that is this backwards and inconsistent, at least they did a good job writing the function and class libraries, right? Well… okay… hmm… no. Of course not. Actually, I do give them credit for creating quite extensive libraries that cover a decent amount of functionality one would expect from a framework like this, however they are still totally cumbersome to use. Let’s have a look at it: At the time of writing this article, the standard PHP installation on my server comes with 2489 predefined functions. The following link takes you to a list I created for quick reference:PHP Function Reference Listing
Tumblr media
Isn’t that nice? What a long list of so many different functions for all kinds of purposes, right?  Well, if you look closer you’ll see it’s actually a huge pile of crap, and here is why: inconsistency all across the board.
NAMING CONVENTIONS
Some functions use prefix + underscore, while others use C-Style (abbreviated words crunched together): strlen vs str_pad, urlencode vs utf8_encode, gethostname vs php_uname.
Even though a lot of string functions start with “str”, not all of them do: trim, substr, chr, levenshtein, gethostname, php_uname.
There are totally mixed occurrences of verb+noun and noun+verb all across the command set: array_merge vs get_class.
Numerous functions can be found in the library that are aliases for each other and do the exact same thing, which is rather confusing to say the least. Granted, it’s “because of an API cleanup”, so I put this one last: chop and rtrim, fwrite and fputs, is_integer and is_int.
Tumblr media
The naming conventions aren’t even the same within one “logical group”, as the mentioned string functions above clearly demonstrate. Another good example I found is the function htmlentities(...), which converts all special characters into equivalent HTML entities. Now, if you want to revert the process you use the function html_entity_decode(...). These functions are direct inverses of each other, yet they use two entirely different naming schemes. 
ORDER OF ARGUMENTS
This is probably a minor complaint, I just really hate inconsistencies in programming languages. The order of parameters varies between different functions of similar kind, e.g. strpos($haystack, $needle, $offset) and array_search($needle, $haystack, $strict). Of course this is nothing too dramatic, but it still requires you to constantly check the function reference for confirmation. Another example is the function int mktime($hour, $minute, $second, $month, $day, $year), which uses American notation for dates. I would have gone with year, month, day, hour, minute, second.
GLOBAL SCOPE & LACK OF MODULARIZATION
Tumblr media
Another thing that really boggles me is that all regular functions are accessible from global scope. This is a huge mess, considering the large number of functions available. Functions of any kind may be called from anywhere. While PHP supports namespaces since version 5.3.0 (oh wow, it took them that long ), they are not used at all for the native function / class sets, which is really unfortunate.
Tumblr media
The namespace separator in PHP is \, which is totally fine for me, although different to what most program languages use. I just wanted to point out the other, rather funny possibilities that were considered: ^^, :>, :) — seriously? That made me giggle a little. My:)Custom:)Library is one happy namespace.  Even the official IRC discussion regarding the implementation details is quite entertaining.
PHP follows the outdated include system we all know (and hopefully dislike) from C/C++. It’s silly copy-and-pasting of code to eventually create one long file that represents the program. PHP comes with four different statements to include code: include, include_once, require and require_once. include_once and require_once cause PHP to check whether the specified file has been included before. If this is the case, it will not be included again. include and require will always include the content, without any such checks. The only difference between the statements involving “include” and those involving “require” is that PHP will abort the execution if a “required” file could not be loaded. The “include” statements will just emit a warning and the execution will be continued.
I really do not know how the “include” statements could possibly be useful. If you are including a file without requiring it, why would you include it in the first place? Most frameworks or programs I checked almost always use require_once — and so do I.
DEGREE OF ABSTRACTION
I seriously don’t understand why the PHP framework sucks this much at abstraction. PHP is supposed to be a high level programming language, intended to greatly simplify the process of creating web applications, yet the provided functions are mostly low level wrappers of C-functions. There is only a very small degree of abstraction between the PHP function and the C-equivalent.
Tumblr media
For example, the function money_format($format, $number) relies on the C-function strfmon. Unfortunately, according to the manual, this function is not natively available on Windows. So certainly the PHP developers implemented the code by themselves in order to guarantee compatibility, right? Yeah sure, as if they’d ever follow the most logical path.  Instead, money_format is just undefined if the C-function is unavailable. Awesome. So, better make sure that all functions you’re intending to use are actually implemented on your target system.
NO UNICODE SUPPORT
Tumblr media
This is one of my major complaints. Seriously guys, it’s 2014 and PHP still has no native support for Unicode. How could this feature possibly not be top priority for years? It’s a freaking web language and not solely intended to control toasters and washing machines. 
While PHP can store Unicode sequences in variables, it is not aware of it and treats it like regular ASCII strings. Applying any of the regular string functions PHP comes with to these sequences will break them or deliver incorrect results.
At least there are some cumbersome ways available to deal with this mess, namely the multi-byte functions that are part of the library. It works — somehow — but it’s just highly annoying beyond belief. However, I should mention that this solution only helps with actual string manipulation. Any other native function that takes a string as an argument still expects plain old ASCII and will break your neck.
Tumblr media
Actually, some time ago I wrote a simple PHP file browser. All it’s supposed to do was to enumerate files in a specified directory on the server. I did already know back then that PHP sucks at handling Unicode, so I developed the system using the multi-byte functions as a design choice from the beginning. Internally, everything string related seemed to work flawlessly up until the point where I tried to scan files with filenames containing non-ASCII characters. While my string handling was correct, I couldn’t do anything about the fact that I was unable to call the file functions with Unicode strings. It just wouldn’t work properly. I was messing around with the system, exec and shell_exec functions to take advantage of operating system features, desperately trying to hack something together that works. It didn’t and I had to give up on that feature, it’s just simply not possible with PHP. 
If anyone can point me into the right direction of solving this problem, please leave me a message and give me a hint. Any help is greatly appreciated.
PLATFORM DEPENDENCY
The thing about platform dependency is another question to discuss. While PHP’s claims of platform independency are technically true, there are a few differences that might just be yet another cause for your program to break. I don’t want to go into details too much since I didn’t write code for Windows based PHP before, however there is one thing I would like to mention: integers come with different bit sizes depending on the underlying operating system. On Linux, the size of an integer variable matches the number of bits the system is natively using, i.e. 32bit or 64bit, whereas on Windows the integer size is always 32bit regardless. This is really a problem in my opinion because there is no way to easily work around this issue except using signed 32bit values as the common denominator, hoping they won’t be auto-cast to float while dealing with file sizes…
Tumblr media
Oh and just for funsies, check out the awesome solution they’ve come up with to solve an issue regarding integer overflow in their PHP code. 
DEPLOYMENT
I have read on numerous websites and blog posts that the simplicity of deployment is a major advantage of PHP. Alright. I have never deployed PHP on a production server by myself, so I will just give them this one. Let’s assume it is easier to deploy PHP than other environments. So what? It simply does not matter. Even if it takes you ten or fifty times longer to properly set up the system, there is no difference in the long run. What the time is really spent on is writing code for the system and that’s probably where PHP loses against other languages if you need to get something done properly that’s beyond the boundaries of a simple “Hello World” program.
PHP’s “drop ‘n run” concept also has a lot of shortcomings. Sure, it’s nice to just drop a script in a folder on the web server and have it run. That is, until you realize that now you have an infinite number of entry points into your application, even though you just need one. If you take a look at the big boys like WordPress, you’ll see that all requests are being redirected to a single entry point and then dispatched further — which is how it should be. Since your entire code hierarchy is accessible by default (without using .htaccess or other mechanisms), you need to protect each PHP file individually against unwanted execution.
DOCUMENTATION
Oh yeah, the infamous PHP Manual. It’s like a mirror of the language you’re using, and in case of PHP it unambiguously reflects all its flaws and shortcomings. While it does provide some information on usage and behavior, it often lacks complete documentation. Sometimes the user comments are much more helpful than the actual text, even though half of them only reveal a fraction of what’s going on and the other half is completely worthless. It also doesn’t help that there is only one manual available that tries to cover all versions of the language at the same time. I think this is a rather bad idea since PHP isn’t doing too well with backwards compatibility.
Also the quality of the manual is just, let’s put it nicely, “below average”. I particularly enjoyed this statement explaining the count function.
Count all elements in an array, or something in an object.
Tumblr media
…”or something”, just hilarious.  Of course I’m aware that the result of the function can be customized by implementing a specific method, but I wonder the amount of confusion that is caused by statements like this with programmers that try to learn the language.
Due to PHP’s popularity, there is actually a large number of tutorials and example codes out there on the Internet, yet most of them are probably examples to demonstrate how things shouldn’t be done with spaghetti code being omnipresent.
MISCELLANEOUS
Here are just some other annoyances that wouldn’t really fit into other paragraphs:
Why do we need thirteen different functions to sort an array?
<?php ?> tags suck because they are required for all PHP code and may cause unwanted whitespace to be sent to the user.
Multithreading still is not one of PHP’s strengths.
Multiple aliases for exactly the same thing, e.g. real / float / double, int / integer, bool / boolean, chop($string) / rtrim($string), etc.
Having to manage a configuration file is just dumb for a programming language.
AN AWESOME ANALOGY
Over on eev.ee, in a popular article on the same topic, I found this great analogy that hits the nail right on its head and perfectly describes how it is working with PHP. Ian Baker even brought the figurative hammer to life. Isn’t it just marvelous?
I can’t even say what’s wrong with PHP, because — okay. Imagine you have uh, a toolbox. A set of tools. Looks okay, standard stuff in there. You pull out a screwdriver, and you see it’s one of those weird tri-headed things. Okay, well, that’s not very useful to you, but you guess it comes in handy sometimes. You pull out the hammer, but to your dismay, it has the claw part on both sides. Still serviceable though, I mean, you can hit nails with the middle of the head holding it sideways. You pull out the pliers, but they don’t have those serrated surfaces; it’s flat and smooth. That’s less useful, but it still turns bolts well enough, so whatever. And on you go. Everything in the box is kind of weird and quirky, but maybe not enough to make it completely worthless. And there’s no clear problem with the set as a whole; it still has all the tools. Now imagine you meet millions of carpenters using this toolbox who tell you “well hey what’s the problem with these tools? They’re all I’ve ever used and they work fine!” And the carpenters show you the houses they’ve built, where every room is a pentagon and the roof is upside-down. And you knock on the front door and it just collapses inwards and they all yell at you for breaking their door. That’s what’s wrong with PHP.
Tumblr media
POSSIBLE EXPLANATION
I have always wondered how PHP could have become this bad, yet still maintain a high level of popularity with an army of sworn fanboys behind. Even though I don’t know why people would think that PHP is a passable or even decent language, I could come up with an explanation for how it could have gotten this messed up. Some time ago I found this rather interesting interview with Rasmus Leerdorf, the creator of PHP. After hearing the following statements, I gained sudden clarity:
There is code, it sort of works, that’s what we go with, that’s always been the default. It doesn’t always lead to consistency but it does lead to getting the features and actually being able to do something. […] at least it gets you there. […] We’d rather have an ugly feature than not having a feature at all.Rasmus Leerdorf
Hands down, all questions answered. There is simply no way PHP could not have turned out that bad with an attitude like that. How can one expect quality when quantity is all that matters?
Tumblr media
At least he’s got a point. PHP somehow works sometimes and you can actually get things done with it. Heck, even this website here is powered by PHP and I got it up and running (Ha! Not anymore!). Then again that’s not the point. Just because you can get things done with it doesn’t mean it’s a good or even a decent programming language. It sucks, and it sucks badly. Will I continue to use it in the feature? Of course I will, because I do not really have a choice. PHP has simply grown too large, you can’t just ignore it. It’s some kind of weird parasitic relationship, or like a tumor that is attached to the World Wide Web. 
Another reason why it turned out like it did, I strongly believe, is that PHP was not designed like other languages but rather grew up from a small toolkit to its current size. There have never been clearly designed rules or goals to achieve. It also didn’t help that Rasmus Leerdorf went with an incredible liberal development policy, placing the fate of the language in the hand of many other programmers who can freely contribute. While this may sound great it might just be the explanation for all these inconsistencies and flaws.…and this is why PHP sucks.
from WordPress http://bit.ly/2wJHqq3 via IFTTT
0 notes
saftutorials-blog · 8 years ago
Text
HOW TO LEARN PHP? PHP TUTORIALS!
Answer: PHP is a most powerful Web programming language. It is a most useful for web development. It is an HTML embedded, server-side scripting language designed for web development.
If any developer wants to build a nice dynamic website so he should be using PHP. Because PHP is an open source programming Language for all. By this PHP Tutorials, you can learn how to make a dynamic website using PHP. 
The PHP full meaning is Hypertext Preprocessor (earlier called, Personal Home Page)
Basic Structure of PHP
<!DOCTYPE html> <html lang="en">     <head>         <title>PHP Tutorials</title>     </head> <body>     <?php         echo "Hello World! This is First PHP Programming.";     ?>     <p>Output</p>     Hello World! This is First PHP Programming. </body> </html>
Output: This code simple generate below output
 PHP DATA TYPES
PHP variables do not need to be declared before the assignment, it is declared at the time of assignment by the leading of dollar sign ($). PHP variables can store different types of data, there is no need to declared data types before or at the time of assignment.
 There are eight data types in PHP
- Strings
- Integers
- Float or Doubles
- Booleans
- Null
- Array
- Objects
- Resources
 How many data types in PHP? There are eight data types in PHP such as Strings, Integers, Float or Doubles, Booleans, Null, Array, Objects, Resources.
 PHP VARIABLE
In the middle of PHP programs, we can store temporary data through PHP variables. There is no need to declared a variable before assigning the value. PHP variable starts from the $ sign.
 How to declare PHP Variable?
PHP Variable declare using dollar sign ($)
How to use PHP Variable?
First declare a PHP variable then it call any place of page or another page where declare page already included.
 PHP Variable Example
<!DOCTYPE html> <html> <body> <?php $php_string = "This is a string"; $php_integer = 357; $php_float = 5.201; ?> <p>This is a PHP string variable example : <?php echo $php_string; ?></p></br> <p>This is a PHP integer variable example : <?php echo $php_integer; ?></p></br> <p>This is a PHP float variable example : <?php echo $php_float; ?></p> </body> </html>
  PHP CONSTANT
PHP Constants is a predefined function of PHP. It is just like a variable but the difference is that PHP Constants used as a global variable and once it is defined it cannot change during the execution of the script.
What is PHP Constants?
PHP Constants is a predefined function of PHP
Syntax of PHP Constants is define(name, value, case-insensitive).
PHP Constant Example
<!DOCTYPE html> <html> <body> <?php define("WISHES", "Hello John !"); ?> <p>This is a PHP Constant variable example : <?php echo WISHES;?></p></br> <p>Same thing will print : <?php echo constant("WISHES");?></p> </body> </html>
 The above code produces the following results
 PHP STRINGS
PHP string is a collection of characters i.e. "Hello John!". A PHP string value must stay with " ".
What is PHP string? When a value stays within " " then it's called be PHP String. Like "Hello John!"
 These are valid example of strings in PHP
<!DOCTYPE html> <html> <body> <?php $first_string = 'This is a string in single quotes'; $second_string = "This is a string in double quotes"; ?> <p>First String : <?php echo $first_string;?></p></br> <p>Second String : <?php echo $second_string;?></p></br> </body> </html>
 The above code produces the following results
  PHP OPERATORS
PHP operators are used to performing some specific operation on variables and values.
What are PHP Operators?
PHP Operators operand one or more than one Operand.
These operators supported by PHP language.
-Assignment Operators
-Arithmetic Operators
-Comparison Operators
-Conditional / Ternary Operators
-Logical / Relational Operators
 PHP IF ELSE IF
You can decide that which part of code want to execute and which part don't by using if and else...if...else statement. You can use this conditional statement for your decision.
 if statement (Execute the part of code when the condition will be true)
if else statement (Execute if condition part of code when the condition will be true otherwise else part of the code will be executed)
if..elseif..else statement (Execute some part of code for more than two conditions)
 Syntax and Example for if statement
if(condition){
// This part of code will be executed if condition will be true
}
 <!DOCTYPE html> <html> <body> <?php $a = 7; $b = 5; if($a > $b) { ?> <p>if part execute when condition true : <?php echo $a . ' is greater than ' .$b;?></p> <?php } ?> </body> </html>
The above code produces the following results
  Syntax and Example for if else statement
 if(condition){
// This part of code will be executed if condition will be true
} else {
// This part of code will be executed if condition will be false
}
<!DOCTYPE html> <html> <body> <?php $a = 7; $b = 5; if($a < $b) { ?> <p>if part execute when condition will be true : <?php echo $a . ' is greater than ' .$b;?></p> <?php } else { ?> <p>else part execute when condition will be false : <?php echo $b . ' is less than ' .$a;?></p> <?php } ?> </body> </html>
 The above code produces the following results
1 note · View note
phptraininginstitue · 5 years ago
Text
php training course
Prerequisites for PHP course in Chennai
Basic computer skills, knowledge of HTML fundamentals. Prior programming experience is helpful but not required.
Overview Of PHP
Static vs. Dynamic Web Sites
Dynamic Content from Databases
Developing Dynamic Internet Applications
Client-Side Scripting vs. Server-Side Scripting
Overview of PHP Advantages and Capabilities
Configuring php.ini PHP vs. ASP
Conditional Constructs
True and False Expressions
if, else and elseif switch/case Statement
The ? (Ternary) Operator
Timestamps
Modularity through Include Files
Using Include Files
The Require Statement Modularizing Code with Functions
Defining and Using Basic Functions of php
PHP Functions
Introduction to Functions
Declaring Functions
Scope
Passing Arguments to Functions
Local and Global Scope
Passing Arguments to Functions by Value and Reference
Variable Scoping and Return Values
Recursion
Coercive and Strict Type Declarations for Parameters and Return Values
Optional and REST Parameters Argument Unpacking
Generator Return Expressions
Dynamic Function Calls
Predefined PHP Functions
PHP 7 New Features
Function Improvements
New Operators
Unicode Codepoint Syntax
Filtered Unserialize
IntlChar Support
Expectations
Basic OOP in PHP
Defining Object Oriented Programming
Creating New Objects in PHP
PHP Object Syntax Using Predefined PHP OOP Libraries
Working with Data Files in PHP
Searching File Contents With Regular Expressions
Changing and Editing File Contents Splitting and Joining Information Inside Files
String Functions
Regular Expression Functions Reading, Writing and Deleting Files Handling File Permissions
File Locking
Reading Directory Contents
Creating and Deleting Directories
Configuring and Using MySQL
Introduction to MySQL Capabilities as a Powerful RDBMS
Installing and Configuring MySQL
Connecting to MySQL
PHP Functions Specific to MySQL
Executing SQL Calls
Using PHP MyAdmin to Configure MySQL
SELECT
INSERT
FETCH
UPDATE
DELETE
0 notes
appziatechnologies · 5 years ago
Text
Improving PHP Application Performance
 1.    Performance check on loops - Try and minimums usage of for each loop. Use for, while, array_map and other predefined functionalities. Reduce the executables in a loop. Try and not use loops that iterate over a large dataset. Break that dataset and if possible use database to perform that operation 
 2.    Memory Check - Check for memory usage peak and normal with provided PHP functionalities. Check whether the variable holding resources objects and large datasets are freeing up memory and whether garbage collector freeing it up? Use assigning 'null' before you 'unset'. Try and use singleton classes as much as you can. 
 3.    Improvement architect - keep discovering places where you can reduce code and maximise execution, you'll be using ternary operators in place of normal condition evaluation blocks etc.,
0 notes